package tt.com.feesmanager.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tt.com.common.enums.Status;
import tt.com.common.model.DeadProject;
import tt.com.common.model.ServeProvidersSubsidy;
import tt.com.common.util.CommonResult;
import tt.com.feesmanager.mapper.DeadprojectMapper;
import tt.com.feesmanager.service.Benefitingpeople;

import java.math.BigDecimal;

@Service
public class BenefitingpeopleImpl extends ServiceImpl<DeadprojectMapper, DeadProject> implements Benefitingpeople {

    @Override
    public CommonResult Benefiting(DeadProject deadProject) {
        ServeProvidersSubsidy serveProvidersSubsidy = new ServeProvidersSubsidy();
        if (serveProvidersSubsidy.getSubsidyType()==null||deadProject==null){
            return CommonResult.buildR(Status.DEFAULT,"该消费者不为惠民减免对象或者不存在该服务项目！无法优惠");
        }else {
            BigDecimal subtract = deadProject.getCost().subtract(serveProvidersSubsidy.getSubsidyPrice());
            deadProject.setCost(subtract);
            return CommonResult.buildR(Status.OK,"优惠成功");
        }
    }
}
